home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <assert.h>
-
- #include "fileinfo.h"
- #include "keyword.h"
- #include "xref.h"
- #include "match.h"
-
- dfFILEINFO fileinfo;
- dfKEYWORD keyword;
- dfXREF xref;
- dfMATCH match;
-
-
- void zap_match_file(void)
- {
- match.rew();
- while (match.next() != -1)
- {
- match.erase();
- }
- }
-
- void process(char *key, int keyno)
- {
- int no_matches = 0;
- strcpy(keyword.name, key);
- if (keyword.find() == -1)
- if (keyword.retrieve() == -1)
- return;
- while (strncmp(keyword.name, key, strlen(key)) == 0)
- {
- xref.keyno = keyword.keyno;
- xref.fileno = 0;
- if (xref.find() == -1)
- assert(xref.retrieve() != -1);
- while (xref.keyno == keyword.keyno)
- {
- match.fileno = xref.fileno;
- match.keyno = keyno;
- if (match.find() == -1)
- {
- match.insert();
- no_matches++;
- }
- if (xref.next() == IM_ERROR)
- break;
- }
- if (keyword.next() == IM_ERROR)
- break;
- }
- printf("%d Matches\n", no_matches);
- }
-
- void report(int count)
- {
- int cur_fileno = -1, x = 0, total_matches = 0;
- match.rew();
- for (;;)
- {
- int retval = match.next();
- if (match.fileno != cur_fileno || retval == -1)
- {
- if (x == count)
- {
- fileinfo.fileno = cur_fileno;
- assert(fileinfo.find() != -1);
- printf("Matching File: %s\n", fileinfo.path);
- total_matches++;
- }
- x = 1;
- cur_fileno = match.fileno;
- }
- else
- x++;
- if (retval == -1)
- break;
- }
- printf("Total Matches: %d\n", total_matches);
- }
-
- int main(int argc, char *argv[])
- {
- if (argc < 2)
- return 0;
- fileinfo.set_idx("File No");
- zap_match_file();
- for (int x = 1; x < argc; x++)
- {
- if (strlen(argv[x]) > 10)
- argv[x][10] = 0;
- strupr(argv[x]);
- printf("Checking Key: %s - ", argv[x]);
- process(argv[x], x - 1);
- }
- report(argc - 1);
- return 0;
- }
-
-